package games.car;


import java.awt.*;

public class Road {

    private int x,y;
    private int yspeed = Config.CAR_DEFAULT_SPEED - 1;
    private int width = Config.ROAD_LINE_WIDTH;
    private int height = Config.ROAD_LINE_HEIGHT;

    public Road(int x, int y){
        this.x = x;
        this.y = y;
    }

    void draw(Graphics g) {
        Color c = g.getColor();
        g.setColor(Color.white);
        g.fillRect(x,y,width,height);
        g.setColor(c);

        move();
    }

    private void move() {
        if (y < Config.WINDOW_HEIGHT - Config.FRAME_WIDTH - yspeed){
            y += yspeed;
        }else{
            y = - Config.ROAD_LINE_HEIGHT;
        }
    }
}
